﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;

namespace COFE.Core.Profile
{
    /// <summary>
    /// Added user creation and login routines.
    /// </summary>
    public interface IUserProfileManager2 : IUserProfileManager
    {
        IUserProfile2 CreateUser(string userName, string password);

        void DeleteUser(string userName);

        IUserProfile2 GetUserProfile(string userName, string password);
        IUserProfile2 GetUserProfile(Guid authorizationKey);

        IEnumerable<IUserProfile2> Users { get; }

        void Logout(Guid authorizationKey);
    }

    public static class IUserProfileManager2Extension
    {
        public static IUserProfile2 Login(this IUserProfileManager2 upm, string userName, string password)
        {
            var retVal = upm.GetUserProfile(userName, password);
            upm.SetCurrentUserProfile(retVal);
            return retVal;
        }

        public static IUserProfile2 Login(this IUserProfileManager2 upm, Guid authorizationKey)
        {
            var retVal = upm.GetUserProfile(authorizationKey);
            upm.SetCurrentUserProfile(retVal);
            return retVal;
        }
    }
    
}
